﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Visit_History_List.aspx.cs"
    MasterPageFile="~/MasterPage.master" Inherits="CallRoute_Visit_History_List" %>

<%@ Register Src="~/UserControl/GridPager.ascx" TagName="GridPager" TagPrefix="uc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
    <title>拜访历史</title>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <script type="text/javascript">
        /*  
        将Date/String类型,解析为String类型.  
        传入String类型,则先解析为Date类型  
        不正确的Date,返回 ''  
        如果时间部分为0,则忽略,只返回日期部分.  
        */
        function formatDate(v) {
            if (v instanceof Date) {
                var y = v.getFullYear();
                var m = v.getMonth() + 1;
                var d = v.getDate();
                var h = v.getHours();
                var i = v.getMinutes();
                var s = v.getSeconds();
                var ms = v.getMilliseconds();
                if (ms > 0)
                    return y + '-' + m + '-' + d + ' ' + h + ':' + i + ':' + s
						+ '.' + ms;
                if (h > 0 || i > 0 || s > 0)
                    return y + '-' + m + '-' + d + ' ' + h + ':' + i + ':' + s;
                return y + '-' + m + '-' + d;
            }
            return '';
        }

        $(function () {
            $('#<%=TxtStartDate.ClientID %>').datebox({
                currentText: '今天',
                closeText: '关闭',
                disabled: false,
                required: true,
                missingMessage: '必填',
                formatter: formatDate
            });
        });
        $(function () {
            $('#<%=txtEndDate.ClientID %>').datebox({
                currentText: '今天',
                closeText: '关闭',
                disabled: false,
                required: true,
                missingMessage: '必填',
                formatter: formatDate
            });
        });
    </script>
    <div>
        <table width="100%">
            <tr runat="server" id="trSearch">
                <td>
                    <table id="wsd_inputtable">
                        <tr>
                            <td class="tabletitle" colspan="6">
                                查询记录
                            </td>
                        </tr>
                        <tr>
                            <td class="tablefield">
                                组织类型:
                            </td>
                            <td nowrap="nowrap" colspan="5">
                                <asp:DropDownList runat="server" ID="ddl_IsThrid" AutoPostBack="true" OnSelectedIndexChanged="ddl_IsThrid_SelectedIndexChanged">
                                   
                                    <asp:ListItem Text="康师傅" Value="1"></asp:ListItem>
                                     <asp:ListItem Text="执行公司" Value="2"></asp:ListItem>
                                </asp:DropDownList>
                            </td>
                        </tr>
                        <tr>
                            <td class="tablefield">
                                开始日期:
                            </td>
                            <td nowrap="nowrap">
                                <asp:TextBox ID="TxtStartDate" runat="server" Width="150"></asp:TextBox>
                            </td>
                            <td class="tablefield">
                                结束日期:
                            </td>
                            <td nowrap="nowrap">
                                <asp:TextBox ID="txtEndDate" runat="server" class="default" Width="150"></asp:TextBox>
                            </td>
                            <td class="tablefield">
                                关键字:
                            </td>
                            <td nowrap="nowrap">
                                <asp:TextBox runat="server" class="default" ID="txtCode"></asp:TextBox>
                                &nbsp;
                            </td>
                        </tr>
                        <tr>
                            <td class="tablefield">
                                部门:
                            </td>
                            <td nowrap="nowrap">
                                <asp:DropDownList ID="ddl_Thrid" Width="150" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddl_Thrid_SelectedIndexChanged">
                                    <asp:ListItem></asp:ListItem>
                                </asp:DropDownList>
                                <asp:TextBox ID="txtOrg" class="default" runat="server" Width="150" onkeydown="alert('请选择部门');return false;"
                                    OnTextChanged="txtOrg_TextChanged"></asp:TextBox>
                                <img id="img_Serach" runat="server" src="../Resources/Images/search.png" alt="查找"
                                    style="cursor: pointer;" onclick="openPopup('../System/PopupOrganization.aspx?NameControlId=<%# txtOrg.UniqueID %>&UserListControlID=<%#txtHidUsers.UniqueID %>&ValueControlId=<%# txtHidOrg.UniqueID %>&SelectType=multi','','300','500');" />
                            </td>
                            <td class="tablefield">
                                巡店督导:
                            </td>
                            <td nowrap="nowrap">
                                <asp:DropDownList ID="ddlMobileUser" runat="server" Width="150">
                                    <asp:ListItem Value="">--所有--</asp:ListItem>
                                </asp:DropDownList>
                            </td>
                            <td class="tablefield">
                                &nbsp;
                            </td>
                            <td nowrap="nowrap">
                                &nbsp;
                            </td>
                        </tr>
                        <tr>
                            <td class="tablefield" colspan="6" align="right">
                                <input id="txtHidOrg" type="hidden" runat="server" />
                                <input id="txtHidUsers" type="hidden" runat="server" />
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtOrg"
                                    ErrorMessage="请选择部门"></asp:RequiredFieldValidator>
                                <asp:Button ID="btnQuery" runat="server" class="wsd_button2" Text="查  询" OnClick="btnQueryCustomer_Click"
                                    Style="height: 21px" />
                                &nbsp;<asp:Button ID="btnQuery0" runat="server" class="wsd_button2" Text="导出报表" OnClick="btnQuery0_Click" />
                            </td>
                        </tr>
                    </table>
                    <br />
                    <table id="wsd_inputtable">
                        <tr>
                            <td width="100%" class="tabletitle">
                                巡店记录列表
                            </td>
                        </tr>
                    </table>
                    <asp:UpdatePanel runat="server" ID="UpdatePanel1" UpdateMode="Conditional">
                        <ContentTemplate>
                            <table id="wsd_listtable" width="100%">
                                <tr>
                                    <td style="width: 100%">
                                        <asp:GridView BorderWidth="0" Width="100%" ID="gvChannelType" runat="server" AutoGenerateColumns="false"
                                            EmptyDataText="没有可显示的数据." EmptyDataRowStyle-Font-Bold="true" EmptyDataRowStyle-HorizontalAlign="Center"
                                            EnableEmptyContentRender="true" DataKeyNames="ID,VISITID" OnRowDataBound="gvChannelType_RowDataBound"
                                            AllowPaging="True" OnPageIndexChanging="gvChannelType_PageIndexChanging" 
                                            PageSize="10">
                                            <HeaderStyle CssClass="titlist" />
                                            <EmptyDataRowStyle HorizontalAlign="Center" Font-Bold="True"></EmptyDataRowStyle>
                                            <Columns>
                                                <asp:TemplateField HeaderText="门店编号">
                                                    <ItemTemplate>
                                                        <asp:HyperLink ID="link_code" runat="server"><%# Eval("CODE")%></asp:HyperLink>
                                                    </ItemTemplate>
                                                    <ControlStyle Font-Underline="false" />
                                                </asp:TemplateField>
                                                <asp:TemplateField HeaderText="门店名称">
                                                    <ItemTemplate>
                                                        <asp:HyperLink ID="link" runat="server"><%# Eval("NAME") %></asp:HyperLink>
                                                    </ItemTemplate>
                                                    <ControlStyle Font-Underline="false" />
                                                </asp:TemplateField>
                                                <asp:BoundField HeaderText="巡店督导" DataField="PERSONNAME" />
                                                <asp:BoundField HeaderText="巡店时间" DataField="START_TIME" />
                                                <asp:TemplateField HeaderText="备注" Visible="false">
                                                    <ItemTemplate>
                                                        <asp:Label runat="server" ID="lblNote" Text='<%# Eval("Note")%>'></asp:Label>
                                                    </ItemTemplate>
                                                </asp:TemplateField>
                                                <asp:BoundField HeaderText="区域层次" DataField="Level" Visible="false" />
                                            </Columns>
                                            <PagerSettings Mode="NumericFirstLast" PageButtonCount="30" />
                                            <RowStyle CssClass="evenline" />
                                            <AlternatingRowStyle CssClass="oddline" />
                                            <PagerSettings Visible="false" />
                                        </asp:GridView>
                                        <uc1:GridPager ID="GridPager1" runat="server" Visible="false" />
                                    </td>
                                </tr>
                            </table>
                        </ContentTemplate>
                        <Triggers>
                            <asp:AsyncPostBackTrigger ControlID="btnQuery" EventName="Click" />
                        </Triggers>
                    </asp:UpdatePanel>
                </td>
            </tr>
        </table>
    </div>
</asp:Content>
